package com.xnyzc.lhy.didi.service.impl.workorder;

import com.xnyzc.lhy.common.entity.DiDiRv;
import com.xnyzc.lhy.common.penum.EDiDiErrorCode;
import com.xnyzc.lhy.common.util.CheckUtil;
import com.xnyzc.lhy.didi.entity.param.work.*;
import com.xnyzc.lhy.didi.entity.param.workorder.CreateWorkOrderParam;
import com.xnyzc.lhy.didi.entity.param.workorder.UpdateWorkOrderParam;
import com.xnyzc.lhy.didi.entity.param.workorder.WorkOrderUrgentParam;
import com.xnyzc.lhy.didi.entity.results.didi.work.BindNumberResults;
import com.xnyzc.lhy.didi.entity.results.didi.work.CreateWorkResults;
import com.xnyzc.lhy.didi.feign.worksheet.IWorkOrderService;
import com.xnyzc.lhy.didi.service.work.WorkOrderService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 滴滴调用工单相关
 * </p>
 *
 * @author wangshuo
 * @since 2019-10-08
 */
@Service
public class WorkOrderServiceImpl implements WorkOrderService {

    @Autowired
    private IWorkOrderService iWorkOrderService;

    /**
     * 新建工单
     * @param param 入参实体
     * @return
     */
    @Override
    public DiDiRv getCreateWorkOrder(CreateWorkOrderParam param){
        CreateWorkResults results=new CreateWorkResults();
        // 参数检查
        if(CheckUtil.objIsEmpty(param.getWorksheet_id(),param.getTimestamp(),param.getContent(),
                param.getDistrict(),param.getCustomer_type(),param.getDict_id(),param.getWfrole())) {
            return DiDiRv.wrap(EDiDiErrorCode.parameterError,results);
        }

        return iWorkOrderService.getCreateWorkOrder(param);
    }

    /**
     * 更新工单
     * @param param 入参实体
     * @return
     */
    @Override
    public DiDiRv getUpdateWorkOrder(UpdateWorkOrderParam param){
        if(CheckUtil.objIsEmpty(param.getAction(),param.getContent(),param.getWorksheet_id())) {
            return DiDiRv.wrapError(EDiDiErrorCode.parameterError);
        }
        return iWorkOrderService.getUpdateWorkOrder(param);
    }

    /**
     * 工单加急接口
     * @return
     */
    @Override
    public DiDiRv getWorkOrderUrgent(WorkOrderUrgentParam workOrderUrgentParam){
        if(StringUtils.isBlank(workOrderUrgentParam.getApp_id())
                || StringUtils.isBlank(workOrderUrgentParam.getWorksheet_id())
                || StringUtils.isBlank(workOrderUrgentParam.getContent())) {
            return DiDiRv.wrapError(EDiDiErrorCode.parameterError);
        }
        return iWorkOrderService.getWorkOrderUrgent(workOrderUrgentParam);
    }

}
